﻿--|--------------------------------------------------------------------------------
--| [GetEntityByName] - Insert Procedure Script for Entity
--|--------------------------------------------------------------------------------
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id (N'[dbo].[GetEntityByName]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) 
  DROP PROCEDURE [dbo].[GetEntityByName]
GO

CREATE PROCEDURE [dbo].[GetEntityByName]
(
	@TeamID int,
	@Name nvarchar(50)
)
AS
	SET NOCOUNT ON

	SELECT
		E.[ID],
		E.[Name],
		E.[Description],
		E.[TeamID],
		E.[EntityTypeID],
		ET.[Name],
		E.[Photo]
	FROM	[Entity] E 
	JOIN [EntityType] ET ON ET.ID = E.[EntityTypeID]
	JOIN [Team] T ON T.ID = E.TeamID
	WHERE
		E.[Name] = @Name
		AND T.ID = @TeamID
GO
  